/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function loadImageTexture(gl, url)
{
    var texture = gl.createTexture();
    texture.image = new Image();
    texture.image.onload = function() { doLoadImageTexture(gl, texture) }
    texture.image.src = url;
    return texture;
}

function doLoadImageTexture(gl, texture)
{
    gl.bindTexture(gl.TEXTURE_2D, texture);
    gl.texImage2D( gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.image);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
    
    //gl.generateMipmap(gl.TEXTURE_2D)
    
    gl.bindTexture(gl.TEXTURE_2D, null);
}